package com.lf.sp.controller.portal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lf.sp.common.ServerResponse;
import com.lf.sp.service.IProductService;

@Controller
@RequestMapping(value="/product/")
public class ProductController {

	@Autowired
	private IProductService iProductService;
	/**
	 * 前台查询商品详细信息
	 * @param productId
	 * @return
	 */
	@RequestMapping(value="get_detail.do")
	@ResponseBody
	public ServerResponse getDetail(Integer productId){
		return iProductService.getProductDetail(productId);
	}
	/**
	 * 前台获取商品分页排序
	 * @param keyword
	 * @param categoryId
	 * @param pageNum
	 * @param pageSize
	 * @param orderBy
	 * @return
	 */
	@RequestMapping(value="get_list.do")
	@ResponseBody
	public ServerResponse getList(@RequestParam(value="keyword",required=false) String keyword,
			@RequestParam(value="categroyId",required =false) Integer categoryId,
			@RequestParam(value="pageNum",defaultValue="1")int pageNum,
			@RequestParam(value="pageSize",defaultValue="10")int pageSize,
			@RequestParam(value="orderBy",defaultValue="") String orderBy){
		
		return iProductService.getProductByKeywordCategory(keyword, categoryId, pageNum, pageSize, orderBy);
	}
	
}
